package packet1;

public class offer_16 {
    public static void main(String[] args) {
        System.out.println(myPow(0.00001,2147483647));
    }
    //快速指数幂运算
    public static double myPow(double x, int n) {
        int f  = 1;
        long N = n;
        if(x == 0 && N != 0)
            return 0;
        if(N == 0)
            return 1;
        if(N < 0)
        {
            f = -1;
            N = -1 * N;
        }
        double sum = 1;
        while(N > 0)
        {
            if(N % 2 == 1)
            sum *= x;
            x *= x;
            N /= 2;
        }
        if(f == -1)
            sum = 1 / sum;
        return sum;
    }
}
